
import mhv.fr.sprite.Sprite;
import mhv.fr.sprite.controller.SpriteController;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Marc-Henri
 */
public class CentipedeHeadController extends SpriteController {

    private long centipedeId;
    final int SPRITE_BULLET = 2;
    final int SPRITE_MUSHROOM_NORMAL = 10;
    final int SPRITE_MUSHROOM_HIT_1 = 11;
    final int SPRITE_MUSHROOM_HIT_2 = 12;

    public long getCentipedeId() {
        return centipedeId;
    }

    public void setCentipedeId(long centipedeId) {
        this.centipedeId = centipedeId;
    }

    @Override
    public void move() {
        GameManager.getInstance().getCentipede(centipedeId).move();
        if ((getGameEntity().getX() == getGameEntity().getNextX()) && (getGameEntity().getY() == getGameEntity().getNextY())) {
            GameManager.getInstance().getCentipede(centipedeId).CalculateNextMove();
        }
    }

    @Override
    public void doCollide(Sprite sp) {
        switch (sp.getType()) {
            case SPRITE_MUSHROOM_NORMAL:
                GameManager.getInstance().getCentipede(centipedeId).CalculateNextMoveByHit(sp.getController().getSpriteId());
                break;
            case SPRITE_MUSHROOM_HIT_1:
                GameManager.getInstance().getCentipede(centipedeId).CalculateNextMoveByHit(sp.getController().getSpriteId());
                break;
            case SPRITE_MUSHROOM_HIT_2:
                GameManager.getInstance().getCentipede(centipedeId).CalculateNextMoveByHit(sp.getController().getSpriteId());
                break;
            case SPRITE_BULLET:
                GameManager.getInstance().getCentipede(centipedeId).DeleteHead();
                if (GameManager.getInstance().getCentipede(centipedeId).getSize() == 0) {
                    GameManager.getInstance().DeleteCentipede(centipedeId);
                }
                break;


        }
    }

    public CentipedeHeadController() {
    }
}
